package com.dm.service.mail;


import org.springframework.mail.MailMessage;
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class MailServiceImpl implements MailService {

    //创建邮箱信息接口类对象
    private SimpleMailMessage message  =new SimpleMailMessage();

    //创建邮箱发送接口类对象
    @Resource
    private JavaMailSender mailSender;


    /**
     * 发送激活邮箱
     *
     * @param mailTo
     * @param activationCode
     * @throws Exception
     */
    @Override
    public void sendActivationMail(String mailTo, String activationCode) throws Exception {
        message.setFrom("2245069339@qq.com"); // 必须要和上文配置的spring.mail.username内容相同
        message.setTo(mailTo);
        message.setSubject("主题：【大觅网】请激活您的账户");
        message.setText(activationCode);
        mailSender.send(message);
    }
}
